﻿@model AntUnion.FrameWork.Model.ModelsExt.CrmUserModel
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>@ViewBag.webFrontTitle</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link href="~/layuiadmin/layui/css/layui.css" rel="stylesheet" />
    <link href="~/layuiadmin/style/admin.css" rel="stylesheet" />
    <link href="~/css/iconfont.css" rel="stylesheet" />
    <script src="~/js/CommonHelper.js"></script>
    <script>
        /^http(s*):\/\//.test(location.href) || alert('请先部署到 localhost 下再访问');

        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return null; //返回参数值
        }

        function Logout() {
            window.location.href = '/Home/Logout?language=' + document.getElementById("languageSelect").value;
        }
    </script>
    <style>
        .layui-side-menu .layui-nav .layui-nav-item a:hover {
            background-color: #009688;
            color: #ffffff;
        }
    </style>
</head>
<body class="layui-layout-body">
    <div id="LAY_app">
        <div class="layui-layout layui-layout-admin">
            <div class="layui-header">
                <!-- 头部区域 -->
                <ul class="layui-nav layui-layout-left">
                    <li class="layui-nav-item layadmin-flexible" lay-unselect>
                        <a id="flexible" href="javascript:;" layadmin-event="flexible" title="侧边伸缩">
                            <i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible"></i>
                        </a>
                    </li>
                    <li class="layui-nav-item" lay-unselect>
                        <a id="refresh" href="javascript:;" layadmin-event="refresh" title="刷新">
                            <i class="layui-icon layui-icon-refresh-3"></i>
                        </a>
                    </li>
                </ul>
                <ul class="layui-nav layui-layout-right" lay-filter="layadmin-layout-right">
                    <li class="layui-nav-item layui-hide-xs" lay-unselect>
                        <button class="layui-icon layui-icon-website layui-btn-primary demo-dropdown-base" id="languageSelect" style="padding: 0 20px;border:0;font-size:18px">
                            <span id="lang">中文</span>
                        </button>
                    </li>
                    @* <li class="layui-nav-item layui-hide-xs" lay-unselect>
                    <a href="javascript:;" layadmin-event="theme">
                    <i class="layui-icon layui-icon-theme"></i>
                    </a>
                    </li>
                    <li class="layui-nav-item layui-hide-xs" lay-unselect>
                    <a href="javascript:;" layadmin-event="fullscreen">
                    <i class="layui-icon layui-icon-screen-full"></i>
                    </a>
                    </li>*@
                    <li class="layui-nav-item" lay-unselect>
                        <a href="javascript:;">
                            <cite>@Model.LoginName</cite>
                        </a>
                        <dl class="layui-nav-child">
                            @*   <dd style="text-align: center;"><a id="UpdatePwd" lay-href="/Console/Users/Edit?id=@Model.Id">修改密码</a></dd>
                            <hr>*@
                            <dd style="text-align: center;"><a id="Logout" href="javascript:Logout();">退出登录</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-unselect>
                        <a href="javascript:;" layadmin-event="more"><i class="layui-icon layui-icon-more-vertical"></i></a>
                    </li>
                </ul>
            </div>

            <!-- 侧边菜单 -->
            <div class="layui-side layui-side-menu">
                <div class="layui-side-scroll">
                    <div class="layui-logo">
                        <img src="@ViewBag.logo" style="height: 30px;width:30px" />
                        <span>@ViewBag.siteName</span>
                    </div>
                    <ul class="layui-nav layui-nav-tree" lay-shrink="all" id="LAY-system-side-menu" lay-filter="layadmin-system-side-menu">
                        @if (ViewBag.menus != null)
                        {
                            List<AntUnion.FrameWork.Model.Models.Menu> menus = ViewBag.menus as List<AntUnion.FrameWork.Model.Models.Menu>;
                            if (menus.Count > 0)
                            {
                                int i = 0;
                                foreach (AntUnion.FrameWork.Model.Models.Menu menu in menus)
                                {
                                    if (i == 0)
                                    {
                                        <li data-name="@menu.Id" class="layui-nav-item layui-nav-itemed">
                                            <a id="@menu.Remark" href="javascript:;" lay-tips="@menu.Names" lay-direction="2">
                                                <cite>
                                                    @menu.Names
                                                </cite>
                                                <i class="layui-icon @menu.Image" style="width:20px">
                                                    @if (menu.msgCount > 0)
                                                    {
                                                        <i class="layui-badge-dot" style="right: 20px;"></i>
                                                    }
                                                </i>
                                            </a>
                                            <dl class="layui-nav-child">
                                                @if (menu.children.Count > 0)
                                                {
                                                    int y = 0;
                                                    foreach (AntUnion.FrameWork.Model.Models.MenuTo item in menu.children)
                                                    {
                                                        if (i == 0 && y == 0)
                                                        {
                                                            <dd data-name="@item.Id" class="layui-this">
                                                                <a id="@item.Remark" lay-href="@item.Url">
                                                                    @item.Names
                                                                    @if (item.msgCount > 0)
                                                                    {
                                                                        <span class="layui-badge">@item.msgCount</span>
                                                                    }
                                                                </a>
                                                            </dd>
                                                        }
                                                        else
                                                        {
                                                            <dd data-name="@item.Id">
                                                                <a id="@item.Remark" lay-href="@item.Url">
                                                                    @item.Names
                                                                    @if (item.msgCount > 0)
                                                                    {
                                                                        <span class="layui-badge">@item.msgCount</span>
                                                                    }
                                                                </a>
                                                            </dd>
                                                        }
                                                        y++;
                                                    }
                                                }
                                            </dl>
                                        </li>
                                    }
                                    else
                                    {
                                        <li data-name="@menu.Id" class="layui-nav-item">
                                            <a id="@menu.Remark" href="javascript:;" lay-tips="@menu.Names" lay-direction="2">
                                                <cite>
                                                    @menu.Names
                                                </cite>
                                                <i class="layui-icon @menu.Image" style="width:20px">
                                                    @if (menu.msgCount > 0)
                                                    {
                                                        <i class="layui-badge-dot" style="right: 20px;"></i>
                                                    }
                                                </i>
                                            </a>
                                            <dl class="layui-nav-child">
                                                @if (menu.children.Count > 0)
                                                {
                                                    int y = 0;
                                                    foreach (AntUnion.FrameWork.Model.Models.MenuTo item in menu.children)
                                                    {
                                                        if (i == 0 && y == 0)
                                                        {
                                                            <dd data-name="@item.Id" class="layui-this">
                                                                <a id="@item.Remark" lay-href="@item.Url">
                                                                    @item.Names
                                                                    @if (item.msgCount > 0)
                                                                    {
                                                                        <span class="layui-badge">@item.msgCount</span>
                                                                    }
                                                                </a>

                                                            </dd>
                                                        }
                                                        else
                                                        {
                                                            <dd data-name="@item.Id">
                                                                <a id="@item.Remark" lay-href="@item.Url">
                                                                    @item.Names
                                                                </a>
                                                                @if (item.msgCount > 0)
                                                                {
                                                                    <span class="layui-badge">@item.msgCount</span>
                                                                }
                                                            </dd>
                                                        }
                                                        y++;
                                                    }
                                                }
                                            </dl>
                                        </li>
                                    }
                                    i++;
                                }
                            }
                        }
                    </ul>
                </div>
            </div>

            <!-- 页面标签 -->
            <div class="layadmin-pagetabs" id="LAY_app_tabs">
                <div class="layui-icon layadmin-tabs-control layui-icon-prev" layadmin-event="leftPage"></div>
                <div class="layui-icon layadmin-tabs-control layui-icon-next" layadmin-event="rightPage"></div>
                <div class="layui-icon layadmin-tabs-control layui-icon-down">
                    <ul class="layui-nav layadmin-tabs-select" lay-filter="layadmin-pagetabs-nav">
                        <li class="layui-nav-item" lay-unselect>
                            <a href="javascript:;"></a>
                            <dl class="layui-nav-child layui-anim-fadein">
                                <dd layadmin-event="closeThisTabs"><a id="closeThisTabs" href="javascript:;">关闭当前标签页</a></dd>
                                <dd layadmin-event="closeOtherTabs"><a id="closeOtherTabs" href="javascript:;">关闭其它标签页</a></dd>
                                <dd layadmin-event="closeAllTabs"><a id="closeAllTabs" href="javascript:;">关闭全部标签页</a></dd>
                            </dl>
                        </li>
                    </ul>
                </div>
                <div class="layui-tab" lay-unauto lay-allowClose="true" lay-filter="layadmin-layout-tabs">
                    <ul class="layui-tab-title" id="LAY_app_tabsheader">
                        <li lay-id="@ViewBag.url" lay-attr="@ViewBag.url" class="layui-this"><i class="layui-icon layui-icon-home"></i></li>
                    </ul>
                </div>
            </div>


            <!-- 主体内容 -->
            <div class="layui-body" id="LAY_app_body">
                <div class="layadmin-tabsbody-item layui-show">
                    <iframe src="@ViewBag.url" frameborder="0" class="layadmin-iframe" id="iframeMain"></iframe>
                </div>
            </div>
            <!-- 辅助元素，一般用于移动设备下遮罩 -->
            <div class="layadmin-body-shade" layadmin-event="shade"></div>
        </div>
    </div>
    <script src="~/layuiadmin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'notice', 'dropdown', 'element'], function () {
            var $ = layui.$
                , notice = layui.notice
                , dropdown = layui.dropdown
            //多语言下拉框
            dropdown.render({
                elem: '#languageSelect', // 绑定元素选择器，此处指向 class 可同时绑定多个元素
                data: [{
                    title: '中文',
                    id: 'user-zh-CN',
                    href: '/Home/Index?language=user-zh-CN'
                }, {
                    title: 'English',
                    id: 'user-en-US',
                    href: '/Home/Index?language=user-en-US'
                }],
                click: function (obj) {
                    var selectedValue = $(this).val();
                    getLanguages(layui, selectedValue);
                }
            });

            notice.options = {
                closeButton: false,//显示关闭按钮
                debug: false,//启用debug
                positionClass: "toast-top-right",//弹出的位置,
                showDuration: "300",//显示的时间
                hideDuration: "1000",//消失的时间
                timeOut: "0",//停留的时间
                extendedTimeOut: "0",//控制时间
                showEasing: "swing",//显示时的动画缓冲方式
                hideEasing: "linear",//消失时的动画缓冲方式
                iconClass: 'toast-info', // 自定义图标，有内置，如不需要则传空 支持layui内置图标/自定义iconfont类名
                onclick: function () {
                    $("#newaudio")[0].pause();
                    $("#newaudio")[0].currentTime = 0;
                }
            };


            /**获取语言 */
            var language = getUrlParam("language");
            if (language) {
                $("#languageSelect").val(language);
            }
            if (language === 'user-zh-CN') {
                $('#lang').text('中文')
            }
            else if (language === 'user-en-US') {
                $('#lang').text('English')
            }
            /**获取语言 End*/

            /**设置语言 */
            $(document).ready(function () {
                console.log(language)
                if (language) {
                    getLanguages(layui, language);
                } else {
                    getLanguages(layui, 'user-zh-CN');
                }
                /**设置语言 End*/

                /**切换语言 */
                //$("#languageSelect").change(function () {
                //    var selectedValue = $(this).val();
                //    window.location.href = '/Console/Home/Index?language=' + selectedValue;
                //});
                /**切换语言 End*/
                var element = layui.element;
                element.on('tabDelete()', function (data) {
                    console.log(this); //当前Tab标题所在的原始DOM元素
                    console.log(data.index); //得到当前Tab的所在下标
                    console.log(data.elem); //得到当前的Tab大容器
                });
                element.on('tab()', function (data) {
                    console.log(this); //当前Tab标题所在的原始DOM元素
                    console.log(data.index); //得到当前Tab的所在下标
                    console.log(data.elem); //得到当前的Tab大容器
                });

            });
            function delTable(layui, tabId) {
                var $ = layui.$;
                console.log($("#LAY_app_tabsheader"));
                $("#LAY_app_tabsheader").children().each(function () {
                    console.log(this);
                });
            }
        });
    </script>
</body>
</html>


